Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-09-22] wooyeol #240#264

Merged
Woo-Yeol merged 1 commit into
mainfrom
wooyeol-#240
Sep 24, 2023
Merged

[2023-09-22] wooyeol #240#264
Woo-Yeol merged 1 commit into
mainfrom
wooyeol-#240

Conversation

@Woo-Yeol
Copy link
Copy Markdown
Member

PR Summary

방문 길이
https://school.programmers.co.kr/learn/courses/30/lessons/49994

풀이시간
10:50 ~ 11:33 (43분)

문제 조건
1 <= len(dirs) : D <= 500

시간 복잡도 :
O(D * (D + D)) = O(D^2)

접근법
무슨 알고리즘으로 풀이 할 수 있을까? -> 시뮬레이션(해쉬 테이블)

  • 방문했던 장소를 기억해야하는 해쉬 테이블 설계
  1. 좌표를 업데이트하는데 범위 밖으로 넘어가서 이동하지 않으면 거리 체크 X
  2. 이동한 좌표와 이동하기 전 좌표의 이동한 길을 방문한적 있는지 확인 후 없으면 중복이 제거된 이동한 거리 증가
    • 무방향성으로 길을 체크해야하기 때문에 (이동 전 좌표에서 이동 후 좌표)와 (이동 후 좌표에서 이동 전 좌표) 모두 체크

@Woo-Yeol Woo-Yeol requested a review from ksumini as a code owner September 22, 2023 02:40
@Woo-Yeol Woo-Yeol self-assigned this Sep 22, 2023
@Woo-Yeol Woo-Yeol requested a review from zsmalla as a code owner September 22, 2023 02:40
@Woo-Yeol Woo-Yeol linked an issue Sep 22, 2023 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@limstonestone limstonestone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저와 풀이가 비슷하신것 같습니당 ㅎㅎ
고생하셨습니다!!

Comment thread Programmers/방문 길이/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우열님 아래에서 양방향 처리를 해주기 때문에

and ((cur_x, cur_y) not in visited[(prev_x, prev_y)])

부분은 필요가 없는 것 같습니다!!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

도현님 말씀처럼 앞의 조건이나 뒤의 조건 중 하나만 써줘도 될 것 같아요 우열님!! 고생하셨습니다~~!!👍👍

Copy link
Copy Markdown
Contributor

@zsmalla zsmalla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해시를 사용해서 지나간 길 체크를 잘 활용하신 것 같습니다! set을 활용해서 길이를 반환하는 것이 정해 같지만 이 방법도 좋은 것 같습니다! 고생하셨습니다 우열님!

Comment thread Programmers/방문 길이/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위 if-else 구절을 조금만 리팩토링 하면 이 친구도 끼어넣을 수 있을 것 같아요! 그 편이 더 깔끔하다는 생각힙니다!

Comment thread Programmers/방문 길이/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

도현님 말씀처럼 앞의 조건이나 뒤의 조건 중 하나만 써줘도 될 것 같아요 우열님!! 고생하셨습니다~~!!👍👍

@Woo-Yeol Woo-Yeol merged commit 9ff6655 into main Sep 24, 2023
@Woo-Yeol Woo-Yeol deleted the wooyeol-#240 branch September 24, 2023 15:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Programmers] 방문 길이

4 participants